package com.hao.eduservice.controller.front;

import com.hao.commonutils.R;
import com.hao.eduservice.entity.EduCourse;
import com.hao.eduservice.entity.EduTeacher;
import com.hao.eduservice.service.EduCourseService;
import com.hao.eduservice.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chenwenhao
 * @version 1.0.0
 * @ClassName IndexFrontController.java
 * @createTime 2020/12/16,20:12
 * @Description     用户前台页面
 */
@RestController
@CrossOrigin
@RequestMapping("/eduservice/indexfront")
public class IndexFrontController {

    @Autowired
    private EduCourseService courseService;
    @Autowired
    private EduTeacherService teacherService;

    /**
     * 用户首页面数据，8条热门课程，4个老师
     *
     * @return {@link R}
     */
    @GetMapping("index")
    public R index(){
        List<EduCourse> courseList = courseService.selectFrontCourse();
        List<EduTeacher> teacherList = teacherService.selectFrontTeacher();
        return R.ok().data("eduList",courseList).data("teacherList",teacherList);
    }

}
